package com.zhixiang.xaec.action.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zhixiang.core.web.action.BaseAction;
import com.zhixiang.xaec.entity.demo.Demo;
import com.zhixiang.xaec.service.demo.DemoService;

//@Controller
@Controller("demoAction")
@Scope("prototype")
public class DemoAction extends BaseAction
{

    /**
     * 意义，目的和功能，以及被用到的地方<br>
     */
    private static final long serialVersionUID = 9084614280564718220L;
    private Demo demo;
    
	public Demo getDemo()
    {
        return demo;
    }

    public void setDemo(Demo demo)
    {
        this.demo = demo;
    }

    @Autowired
    public DemoService demoServie;
    
    public String list(){
//        demoServie.test();
        System.out.println("123");
        return SUCCESS;
    }
    
    public String save(){
        Demo demo = new Demo();
//        demo.setId(1);
        demo.setName("zhangsan");
        demoServie.save(demo);
        return SUCCESS;
    }
    
    public String get(){
        Demo demo = demoServie.get(1);
        System.out.println(demo.getName());
        return "success";
    }
    
//	@Test
//    public void test(){
//    	ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("conf/app-context.xml");
//    	DemoService   testservice=(DemoService) ac.getBean("demoService");
//    	DemoDao   demodao=(DemoDao) ac.getBean("demoDao");
//    	    testservice.test();
//    }
	
	
}
